package org.example.platform.beans.factory;

/**
 * 抽象类定义模版方法
 */
public abstract class AbstractBeanFactory extends DefaultSingletonBeanRegistry implements BeanFactory {


    @Override
    public Object getBean(String name,Object[] args) throws Exception {
        Object bean = getSingleton(name);
        if(null != bean){
            return bean;
        }
        BeanDefinition beanDefinition = getBeanDefinition(name);
        return createBean(name,beanDefinition,args);
    }

    protected abstract BeanDefinition getBeanDefinition(String beanName) throws Exception;

    protected abstract Object createBean(String beanName, BeanDefinition beanDefinition, Object[] args) throws Exception;
//    abstract Object createBean(String beanName,BeanDefinition beanDefinition) throws Exception;

}
